home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Video
/
World of Video.iso
/
gfxprograms
/
boards
/
retina
/
rblanker.lha
/
RBlankers
/
RSpliner.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-13
|
21KB
|
738 lines
/*
* RSpliner
*
* A screen blanker for the Retina graphics card.
* By Michael Heinz, 30 March, 1994
*
*/
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/execbase.h>
#include <graphics/displayinfo.h>
#include <intuition/intuitionbase.h>
#include <intuition/gadgetclass.h>
#include <libraries/commodities.h>
#include <libraries/gadtools.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <utility/tagitem.h>
#include <clib/alib_protos.h>
#include <clib/commodities_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/macros.h>
#include <clib/retina_protos.h>
#include <retina/retina.h>
#include <string.h>
#include <stdlib.h>
#include <pragmas/commodities_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/retina_pragmas.h>
#include "blanker.h"
UBYTE *VersionString = "$VER: RSpliner 2.0 (By Michael Heinz)";
unsigned char color_table[] =
{
0, 0, 0, 0, 0, 70, 0, 0, 76, 0, 0, 82, 0, 0, 88, 0, 0, 94,
0, 0, 100, 0, 0, 106, 0, 0, 112, 0, 0, 118, 0, 0, 124, 0, 0, 130,
0, 0, 136, 0, 0, 142, 0, 0, 148, 0, 0, 154, 0, 0, 160, 0, 0, 166,
0, 0, 172, 0, 0, 178, 0, 0, 184, 0, 0, 190, 0, 0, 196, 0, 0, 202,
0, 0, 208, 0, 0, 214, 0, 0, 220, 0, 0, 226, 0, 0, 232, 0, 0, 238,
0, 0, 244, 0, 0, 250, 0, 0, 255, 4, 0, 255, 8, 0, 255, 12, 0, 255,
16, 0, 255, 20, 0, 255, 24, 0, 255, 28, 0, 255, 32, 0, 255, 36, 0, 255,
40, 0, 255, 44, 0, 255, 48, 0, 255, 52, 0, 255, 56, 0, 255, 60, 0, 255,
64, 0, 255, 68, 0, 255, 72, 0, 255, 76, 0, 255, 80, 0, 255, 84, 0, 255,
88, 0, 255, 92, 0, 255, 96, 0, 255, 100, 0, 255, 104, 0, 255, 108, 0, 255,
112, 0, 255, 116, 0, 255, 120, 0, 255, 124, 0, 255, 128, 0, 255, 132, 0, 255,
136, 0, 255, 140, 0, 255, 144, 0, 255, 148, 0, 255, 152, 0, 255, 156, 0, 255,
160, 0, 255, 164, 0, 255, 168, 0, 255, 172, 0, 255, 176, 0, 255, 180, 0, 255,
184, 0, 255, 188, 0, 255, 192, 0, 255, 196, 0, 255, 200, 0, 255, 204, 0, 255,
208, 0, 255, 212, 0, 255, 216, 0, 255, 220, 0, 255, 224, 0, 255, 228, 0, 255,
232, 0, 255, 236, 0, 255, 240, 0, 255, 244, 0, 255, 248, 0, 255, 252, 0, 255,
255, 0, 252, 255, 0, 248, 255, 0, 244, 255, 0, 240, 255, 0, 236, 255, 0, 232,
255, 0, 228, 255, 0, 224, 255, 0, 220, 255, 0, 216, 255, 0, 212, 255, 0, 208,
255, 0, 204, 255, 0, 200, 255, 0, 196, 255, 0, 192, 255, 0, 188, 255, 0, 184,
255, 0, 180, 255, 0, 176, 255, 0, 172, 255, 0, 168, 255, 0, 164, 255, 0, 160,
255, 0, 156, 255, 0, 152, 255, 0, 148, 255, 0, 144, 255, 0, 140, 255, 0, 136,
255, 0, 132, 255, 0, 128, 255, 0, 124, 255, 0, 120, 255, 0, 116, 255, 0, 112,
255, 0, 108, 255, 0, 104, 255, 0, 100, 255, 0, 96, 255, 0, 92, 255, 0, 88,
255, 0, 84, 255, 0, 80, 255, 0, 76, 255, 0, 72, 255, 0, 68, 255, 0, 64, 255, 0, 60,
255, 0, 56, 255, 0, 52, 255, 0, 48, 255, 0, 44, 255, 0, 40, 255, 0, 36, 255, 0, 32,
255, 0, 28, 255, 0, 24, 255, 0, 20, 255, 0, 16, 255, 0, 12, 255, 0, 8, 255, 0, 4,
255, 0, 0, 255, 4, 0, 255, 8, 0, 255, 12, 0, 255, 16, 0, 255, 20, 0, 255, 24, 0,
255, 28, 0, 255, 32, 0, 255, 36, 0, 255, 40, 0, 255, 44, 0, 255, 48, 0, 255, 52, 0,
255, 56, 0, 255, 60, 0, 255, 64, 0, 255, 68, 0, 255, 72, 0, 255, 76, 0,
255, 80, 0, 255, 84, 0, 255, 88, 0, 255, 92, 0, 255, 96, 0, 255, 100, 0,
255, 104, 0, 255, 108, 0, 255, 112, 0, 255, 116, 0, 255, 120, 0, 255, 124, 0,
255, 128, 0, 255, 132, 0, 255, 136, 0, 255, 140, 0, 255, 144, 0, 255, 148, 0,
255, 152, 0, 255, 156, 0, 255, 160, 0, 255, 164, 0, 255, 168, 0, 255, 172, 0, 255, 176, 0,
255, 180, 0, 255, 184, 0, 255, 188, 0, 255, 192, 0, 255, 196, 0, 255, 200, 0,
255, 204, 0, 255, 208, 0, 255, 212, 0, 255, 216, 0, 255, 220, 0, 255, 224, 0,
255, 228, 0, 255, 232, 0, 255, 236, 0, 255, 240, 0, 255, 244, 0, 255, 248, 0,
255, 252, 0, 255, 255, 0, 255, 255, 8, 255, 255, 16, 255, 255, 24, 255, 255, 32,
255, 255, 40, 255, 255, 48, 255, 255, 56, 255, 255, 64, 255, 255, 72, 255, 255, 80,
255, 255, 88, 255, 255, 96, 255, 255, 104, 255, 255, 112, 255, 255, 120, 255, 255, 128,
255, 255, 136, 255, 255, 144, 255, 255, 152, 255, 255, 160, 255, 255, 168, 255, 255, 176,
255, 255, 184, 255, 255, 192, 255, 255, 200, 255, 255, 208, 255, 255, 216, 255, 255, 224,
255, 255, 232, 255, 255, 240, 255, 255, 248, 255, 255, 255,
};
/*
* A handy request structure for reporting that we've up and died.
*/
struct EasyStruct quitreq =
{
sizeof(struct EasyStruct),
0,
"RSpliner",
"RSpliner has suffered an untimely demise\ndue to: %s",
"OK|OK"
};
/*
* Definitions for our Commodity
*/
struct NewBroker NewBroker =
{NB_VERSION, "RSpliner ", NULL,
"Silly Rabbit, Qix are for Qids!", NBU_NOTIFY | NBU_UNIQUE, COF_SHOW_HIDE,
0, NULL, 0};
#define MAX_SPEED 20L
#define MAX_LINES 300L
#define LINE_BUF 512L
#define MIN_LINES 10L
#define DEF_LINES 100L
#define DEF_SPEED 10L
#define DELTA_V 10L
LONG NumLines, Speed;
typedef struct {
unsigned char color;
int cur_point;
int last_point;
int max_points;
int tic, speed;
int xv1, yv1, xv2, yv2;
int point_list[LINE_BUF][4];
} PList;
PList plist;
/*
* Definitions for our configuration window
*/
struct NewWindow NewBlankerWindow =
{
80, 16, 0, 0, 0, 1,
IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_GADGETDOWN |
IDCMP_GADGETUP | IDCMP_VANILLAKEY | SLIDERIDCMP | LISTVIEWIDCMP,
WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SIMPLE_REFRESH,
NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
WBENCHSCREEN
};
struct Window *BlankerWindow;
#define GID_HIDE 1
#define GID_BLANK 2
#define GID_QUIT 3
#define GID_TIMEOUT 4
#define GID_CLIENT 5
#define GID_LINES 6
#define GID_SPEED 7
#define NUM_GADS 7
struct VisualInfo *BlankerVisualInfo;
struct Gadget *BlankerGadgets;
struct TextAttr BlankerAttr =
{"topaz.font", TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT};
struct NewGadget NewBlankerGadgets[NUM_GADS] =
{16, 101, 48, 12, "_Hide", &BlankerAttr, GID_HIDE, PLACETEXT_IN, NULL, NULL,
80, 101, 48, 12, "_Blank", &BlankerAttr, GID_BLANK, PLACETEXT_IN, NULL, NULL,
144, 101, 48, 12, "_Quit", &BlankerAttr, GID_QUIT, PLACETEXT_IN, NULL, NULL,
136, 5, 66, 12, "Timeout", &BlankerAttr, GID_TIMEOUT, PLACETEXT_LEFT, NULL, NULL,
136, 21, 66, 12, "Client Timeout", &BlankerAttr, GID_CLIENT, PLACETEXT_LEFT, NULL, NULL,
136, 53, 66, 12, "Speed ", &BlankerAttr, GID_SPEED, PLACETEXT_LEFT, NULL, NULL,
136, 69, 66, 12, "Lines ", &BlankerAttr, GID_LINES, PLACETEXT_LEFT, NULL, NULL,
};
UBYTE BlankerGadgetKinds[NUM_GADS] =
{
BUTTON_KIND, BUTTON_KIND, BUTTON_KIND, INTEGER_KIND, INTEGER_KIND, SLIDER_KIND,
SLIDER_KIND,
};
struct TagItem ButtonGadgetTags[] =
{GT_Underscore, (ULONG) '_', TAG_DONE, 0L};
struct TagItem TimeGadgetTags[] =
{GTIN_Number, 0L, GTIN_MaxChars, 4L, TAG_DONE, 0L};
struct TagItem ClientGadgetTags[] =
{GTIN_Number, 0L, GTIN_MaxChars, 2L, TAG_DONE, 0L};
struct TagItem SpeedGadgetTags[] =
{GTSL_Level, 0L, GTSL_Min, 1L, GTSL_Max, MAX_SPEED, GTSL_LevelFormat, 0L,
GTSL_LevelPlace, PLACETEXT_LEFT, GTSL_MaxLevelLen, 2L, GA_RELVERIFY, TRUE,
TAG_DONE, 0L};
struct TagItem LinesGadgetTags[] =
{GTSL_Level, 0L, GTSL_Min, MIN_LINES, GTSL_Max, MAX_LINES, GTSL_LevelFormat, 0L,
GTSL_LevelPlace, PLACETEXT_LEFT, GTSL_MaxLevelLen, 3L, GA_RELVERIFY, TRUE,
TAG_DONE, 0L};
struct TagItem *BlankerGadgetTagLists[NUM_GADS] =
{
&ButtonGadgetTags[0],
&ButtonGadgetTags[0],
&ButtonGadgetTags[0],
&TimeGadgetTags[0],
&ClientGadgetTags[0],
&SpeedGadgetTags[0],
&LinesGadgetTags[0],
};
void
CloseBlankerWindow(void)
{
if (BlankerWindow) {
/*
* We save the current position of the window
* so it will re-open in the same place, later.
*/
NewBlankerWindow.LeftEdge = BlankerWindow->LeftEdge;
NewBlankerWindow.TopEdge = BlankerWindow->TopEdge;
RemTool(BlankerGadgets);
RemTool(BlankerVisualInfo);
RemTool(BlankerWindow);
BlankerWindow = NULL;
}
}
void
OpenBlankerWindow(void)
{
struct Gadget *Ptr;
UWORD Index;
static char Title[80];
if (BlankerWindow == NULL) {
strcpy(Title, "RSpliner = <");
strcat(Title, PopKey);
strcat(Title, ">");
if (BlankerWindow = OpenWindowTags(&NewBlankerWindow, WA_Title, Title,
WA_AutoAdjust, TRUE, WA_InnerWidth,
212, WA_InnerHeight, 118, TAG_DONE)) {
AddTool(BlankerWindow, CloseWindow, NULL, "Could not open the window.");
if ((BlankerVisualInfo = GetVisualInfo(BlankerWindow->WScreen, TAG_DONE))
== NULL) {
RemTool(BlankerWindow);
return;
}
AddTool(BlankerVisualInfo, FreeVisualInfo, 0L,
"Couldn't get visual data.");
BlankerGadgets = NULL;
if ((Ptr = CreateContext(&BlankerGadgets)) == NULL) {
RemTool(BlankerVisualInfo);
RemTool(BlankerWindow);
return;
}
AddTool(Ptr, FreeGadgets, 0L, "Couldn't allocate the gadgets.");
/*
* Here we re-load the gadgets with the current settings.
*/
TimeGadgetTags[0].ti_Data = (ULONG) TimeOut;
ClientGadgetTags[0].ti_Data = (ULONG) ClientTimeOut;
SpeedGadgetTags[0].ti_Data = (ULONG) Speed;
SpeedGadgetTags[3].ti_Data = (ULONG) "%2ld";
LinesGadgetTags[0].ti_Data = (ULONG) NumLines;
LinesGadgetTags[3].ti_Data = (ULONG) "%3ld";
for (Index = 0L; Index < NUM_GADS; Index++) {
NewBlankerGadgets[Index].ng_TopEdge += BlankerWindow->BorderTop;
NewBlankerGadgets[Index].ng_VisualInfo = BlankerVisualInfo;
Ptr = CreateGadgetA((ULONG) BlankerGadgetKinds[Index], Ptr,
&NewBlankerGadgets[Index],
BlankerGadgetTagLists[Index]);
if (Ptr == NULL) {
CloseBlankerWindow();
return;
}
NewBlankerGadgets[Index].ng_TopEdge -= BlankerWindow->BorderTop;
}
AddGList(BlankerWindow, BlankerGadgets, 0L, -1L, NULL);
RefreshGadgets(BlankerGadgets, BlankerWindow, NULL);
GT_RefreshWindow(BlankerWindow, NULL);
}
}
ScreenToFront(BlankerWindow->WScreen);
WindowToFront(BlankerWindow);
ActivateWindow(BlankerWindow);
}
WORD __inline
Insure1(WORD val)
{
return (WORD)((val == 0) ? (WORD)1 : val);
}
/*
* Create the list of points.
*/
void *__regargs
CreateLines(struct RetinaScreen * Screen,
LONG NumLines, LONG Speed)
{
int i;
if (!Screen)
return NULL;
for (i = 0; i < LINE_BUF; i++) {
plist.point_list[i][0] = -1;
plist.point_list[i][1] = -1;
plist.point_list[i][2] = -1;
plist.point_list[i][3] = -1;
}
plist.color = 1;
plist.max_points = NumLines;
plist.speed = Speed;
plist.last_point = 0;
plist.cur_point = NumLines;
plist.point_list[NumLines][0] = Random(Screen->rs_Width);
plist.point_list[NumLines][1] = Random(Screen->rs_Height);
plist.point_list[NumLines][2] = Random(Screen->rs_Width);
plist.point_list[NumLines][3] = Random(Screen->rs_Height);
plist.xv1 = Insure1(RAND(DELTA_V));
plist.yv1 = Insure1(RAND(DELTA_V));
plist.xv2 = Insure1(RAND(DELTA_V));
plist.yv2 = Insure1(RAND(DELTA_V));
return (void *)&plist;
}
int __inline __regargs
Bound(int l, int *m, int u)
{
if (*m < l) {
*m = l;
return 1;
}
if (*m >= u) {
*m = u - 1;
return 1;
}
return 0;
}
/*
* move the Lines and redraw them
*/
void __regargs
DrawLines(void *xplist, struct RetinaScreen *rs)
{
int *pl;
PList *plist=xplist;
/*
* If we don't have a screen, don't draw on it! (duh.)
*/
if (!rs)
return;
if (plist->tic) {
plist->tic--;
return;
}
plist->tic = Insure1(MAX_SPEED - plist->speed);
pl = plist->point_list[plist->cur_point];
Retina_SetAPen(rs, plist->color);
plist->color++;
Retina_Line(rs, pl[0], pl[1], pl[2], pl[3]);
plist->cur_point = (plist->cur_point + 1) % LINE_BUF;
plist->point_list[plist->cur_point][0] = pl[0] + plist->xv1;
plist->point_list[plist->cur_point][1] = pl[1] + plist->yv1;
plist->point_list[plist->cur_point][2] = pl[2] + plist->xv2;
plist->point_list[plist->cur_point][3] = pl[3] + plist->yv2;
if (Bound(0, &plist->point_list[plist->cur_point][0], rs->rs_Width)) {
if (plist->xv1 > 0) {
plist->xv1 = -Insure1(Random(DELTA_V));
} else {
plist->xv1 = Insure1(Random(DELTA_V));
}
}
if (Bound(0, &plist->point_list[plist->cur_point][1], rs->rs_Height)) {
if (plist->yv1 > 0) {
plist->yv1 = -Insure1(Random(DELTA_V));
} else {
plist->yv1 = Insure1(Random(DELTA_V));
}
}
if (Bound(0, &plist->point_list[plist->cur_point][2], rs->rs_Width)) {
if (plist->xv2 > 0) {
plist->xv2 = -Insure1(Random(DELTA_V));
} else {
plist->xv2 = Insure1(Random(DELTA_V));
}
}
if (Bound(0, &plist->point_list[plist->cur_point][3], rs->rs_Height)) {
if (plist->yv2 > 0) {
plist->yv2 = -Insure1(Random(DELTA_V));
} else {
plist->yv2 = Insure1(Random(DELTA_V));
}
}
Retina_SetAPen(rs, 0);
pl = plist->point_list[plist->last_point];
if (pl[0] >= 0)
Retina_Line(rs, pl[0], pl[1], pl[2], pl[3]);
plist->last_point = (plist->last_point + 1) % LINE_BUF;
}
void
main(LONG argc, UBYTE * argv[])
{
char **ToolTypes;
CxObj *Broker, *ObjectList, *Filter;
struct IntuiMessage *IntMsg;
CxMsg *BlankerCxMsg;
LONG ThisTimeOut, TimeUntilBlank, TimeUntilBlack;
struct RetinaScreen *BlankerScreen = NULL;
struct MsgPort *ClientPort = NULL;
int BlankFlag = 0;
/*
* open our Libraries
*/
AddTool(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",
37L), CloseLibrary, 0L,
"Couldn't open the intuition.library.");
AddTool(IconBase = OpenLibrary("icon.library", 37L), CloseLibrary, 0L,
"Couldn't open the icon library.");
AddTool(CxBase = OpenLibrary("commodities.library", 37L), CloseLibrary, 0L,
"Couldn't open the commoidities library.");
AddTool(GadToolsBase = OpenLibrary("gadtools.library", 37L), CloseLibrary, 0L,
"Couldn't open the gadtools library.");
AddTool(RetinaBase = (struct _xy_RetinaBase *)OpenLibrary("retina.library", 7L),
CloseLibrary, 0L, "Couldn't open the Retina library.");
/*
* get our Arguments
*/
if (ToolTypes = ArgArrayInit(argc, argv))
AddTool(ToolTypes, ArgArrayDone, 0L, NULL);
/*
* get some Signals
*/
ServerProcess = SysBase->ThisTask;
if ((bsp_TimerSig = AllocSignal(-1L)) == -1)
Quit(10, "Could not allocate a signal.");
AddTool((void *)bsp_TimerSig, FreeSignal, 0L, NULL);
if ((bsp_InputSig = AllocSignal(-1L)) == -1)
Quit(10, "Could not allocate a signal.");
AddTool((void *)bsp_InputSig, FreeSignal, 0L, NULL);
if ((bsp_ClientSig = AllocSignal(-1L)) == -1)
Quit(10, "Could not allocate a signal.");
AddTool((void *)bsp_ClientSig, FreeSignal, 0L, NULL);
/*
* initialize our Broker = install us as a Commodity
*/
AddTool(CxPort = CreateMsgPort(), DeleteMsgPortSafely, 0L,
"Failed to create a port.");
NewBroker.nb_Descr = &VersionString[6];
NewBroker.nb_Pri = ArgInt(ToolTypes, "CX_PRIORITY", DEF_CX_PRI);
NewBroker.nb_Port = CxPort;
AddTool(Broker = CxBroker(&NewBroker, NULL), DeleteCxObjAll, 0L,
NULL);
/*
* get Time Out, Client Time Out and Display mode
*/
TimeOut = ArgIntRange(ToolTypes, "TIMEOUT", 1L, DEF_TIMEOUT, MAX_TIMEOUT);
ClientTimeOut = ArgIntRange(ToolTypes, "CLIENTTIMEOUT", 1L, DEF_CLIENT_TIMEOUT,
MAX_CLIENT_TIMEOUT);
/*
* get Parameters for Line Movement
*/
NumLines = ArgIntRange(ToolTypes, "LINES", MIN_LINES, DEF_LINES, MAX_LINES);
Speed = ArgIntRange(ToolTypes, "SPEED", 1L, DEF_SPEED, MAX_SPEED);
/*
* install our hot keys
*/
PopKey = ArgString(ToolTypes, "CX_POPKEY", DEF_POPKEY);
BlankKey = ArgString(ToolTypes, "BLANKKEY", DEF_BLANKKEY);
if ((Filter = HotKey(PopKey, CxPort, HOTKEY_OPEN_WINDOW)) == NULL)
Quit(10, "The CX_POPKEY tool type is invalid.");
else
AttachCxObj(Broker, Filter);
if (CxObjError(Filter))
Quit(10, "Could not link to the commodity list.");
if ((Filter = HotKey(BlankKey, CxPort, HOTKEY_BLANK_SCREEN)) == NULL)
Quit(10, "The BLANKKEY tool type is invalid.");
else
AttachCxObj(Broker, Filter);
if (CxObjError(Filter))
Quit(10, "Could not link to the commodity list.");
/*
* install our "InputHandler"
*/
ObjectList = CxCustom(BlankerAction, 0L);
AttachCxObj(Broker, ObjectList);
if (CxObjError(ObjectList))
Quit(10, "Could not link to the commodity list.");
(void)ActivateCxObj(Broker, TRUE);
AddTool(Broker, ActivateCxObj, 0L, "The broker broke.");
/*
* open Window on startup if not forbidden
*/
if (stricmp(ArgString(ToolTypes, "CX_POPUP", ""), "NO"))
OpenBlankerWindow();
/*
* increase our Priority
*/
AddTool(FindTask(NULL), SetTaskPri, (LONG) SetTaskPri(FindTask(NULL), SERVER_PRI),
"Findtask failed!");
/*
* start the Loop
*/
TimeUntilBlank = ThisTimeOut = 10L * TimeOut;
TimeUntilBlack = 10L * ClientTimeOut;
FOREVER
{
ULONG Mask;
if (BlankerWindow)
Mask = Wait(MASK(bsp_TimerSig) | MASK(bsp_InputSig) | MASK(bsp_ClientSig) |
MASK(CxPort->mp_SigBit) |
MASK(BlankerWindow->UserPort->mp_SigBit) |
SIGBREAKF_CTRL_C);
else
Mask = Wait(MASK(bsp_TimerSig) | MASK(bsp_InputSig) | MASK(bsp_ClientSig) |
MASK(CxPort->mp_SigBit) | SIGBREAKF_CTRL_C);
/*
* process Window Events
*/
while ((BlankerWindow != NULL) && (IntMsg =
GT_GetIMsg(BlankerWindow->UserPort)))
switch (IntMsg->Class) {
struct Gadget *Clicked;
UWORD Code;
case IDCMP_CLOSEWINDOW:
GT_ReplyIMsg(IntMsg);
CloseBlankerWindow();
break;
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh(BlankerWindow);
GT_EndRefresh(BlankerWindow, TRUE);
break;
case IDCMP_GADGETUP:
Code = IntMsg->Code;
Clicked = (struct Gadget *)IntMsg->IAddress;
GT_ReplyIMsg(IntMsg);
switch (Clicked->GadgetID) {
case GID_HIDE:
CloseBlankerWindow();
break;
case GID_QUIT:
Quit(0, "Normal Termination.");
case GID_BLANK:
if (TimeUntilBlank)
TimeUntilBlank = ThisTimeOut = 2L;
break;
case GID_TIMEOUT:
if (GetNum(BlankerWindow, Clicked, 1L, &TimeOut, MAX_TIMEOUT))
TimeUntilBlank = ThisTimeOut = 10L * TimeOut;
break;
case GID_CLIENT:
if (GetNum(BlankerWindow, Clicked, 1L, &ClientTimeOut, MAX_CLIENT_TIMEOUT))
TimeUntilBlack = 10L * ClientTimeOut;
break;
case GID_LINES:
NumLines = Code;
break;
case GID_SPEED:
Speed = Code;
break;
}
break;
case IDCMP_VANILLAKEY:
Code = IntMsg->Code;
GT_ReplyIMsg(IntMsg);
switch ((char)Code) {
case 'H':
case 'h':
CloseBlankerWindow();
break;
case 'Q':
case 'q':
Quit(0, "Normal Termination.");
case 'B':
case 'b':
if (TimeUntilBlank)
TimeUntilBlank = ThisTimeOut = 2L;
}
break;
default:
GT_ReplyIMsg(IntMsg);
}
/*
* process Commodity Messages
*/
while (BlankerCxMsg = (CxMsg *) GetMsg(CxPort))
HandleCxMsg(Broker, BlankerCxMsg, &TimeUntilBlank, &ThisTimeOut);
/*
* check for <CTRL>-C
*/
if (Mask & SIGBREAKF_CTRL_C)
Quit(0, "Normal Termination.");
/*
* Input detected, unblank if necessary
*/
if (Mask & MASK(bsp_InputSig)) {
if (BlankFlag) {
if (ClientPort)
RemTool(ClientPort);
if (BlankerScreen) {
SpritesOn(BlankerScreen);
RemTool(BlankerScreen);
} else
Retina_DisplayOn();
BlankFlag = 0;
ThisTimeOut = 10L * TimeOut;
}
TimeUntilBlank = ThisTimeOut;
}
/*
* client has confirmed that it is still alive
*/
if (Mask & MASK(bsp_ClientSig)) {
if (BlankerScreen)
Retina_DisplayOn();
TimeUntilBlack = 10L * ClientTimeOut;
BlankFlag = 1;
}
/*
* 1/10 sec is over
*/
if (Mask & MASK(bsp_TimerSig))
if (TimeUntilBlank) {
TimeUntilBlank--;
if (TimeUntilBlank == 0L) { /*
* Time Out reached,
* blank * the screen
*/
struct ClientMessage ClientMessage;
BlankFlag = 1;
BlankerScreen = CreateScreen(color_table);
if (BlankerScreen)
AddTool(BlankerScreen, DestroyScreen, 0L, NULL);
else
/*
* do this if we're completely out of video
* memory.
*/
Retina_DisplayOff();
ClientMessage.bcm_Screen = BlankerScreen;
ClientMessage.bcm_SigMask = 1L << bsp_ClientSig;
ClientMessage.bcm_Lines = NumLines;
ClientMessage.bcm_Speed = Speed;
if (ClientPort = CreateBlankerClient(RLinesClientProcess,
&ClientMessage)) {
TimeUntilBlack = 10L * ClientTimeOut;
/*
* try to start Client
*/
AddTool(ClientPort, DeleteBlankerClient, 0L, NULL);
}
}
} else {
if ((BlankerScreen) && (RetinaBase->rb_FirstScreen != BlankerScreen)) {
Retina_ScreenToFront(BlankerScreen);
SpritesOff(BlankerScreen);
}
if (TimeUntilBlack) {
TimeUntilBlack--;
if (TimeUntilBlack == 0L)
Retina_DisplayOff(); /*
* Client Time Out *
* reached, turn entire
* * screen black
*/
}
}
}
}